package com.rc.saas.mini.hlhtcec2.parking;

import com.rc.saas.mini.model.hlhtsk.HlhtskBizOperator;
import com.rc.saas.mini.model.hlhtsk.HlhtskBizTenant;
import com.rc.saas.mini.vo.hlhtcec2.NotifyCarNumReq;
import com.rc.saas.mini.vo.hlhtcec2.TokenResult;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.stereotype.Component;

/**
 * @author wangzhengwei
 * @create 2021/12/23
 */
@Component
public class HlhtParkingAssemble {
    private static Logger logger = LogManager.getLogger(HlhtParkingAssemble.class);

    /**
     * 停车减免车牌上送
     * 该推送接口用于申请停车减免,推送的信息有订单号、充电车牌号、启动时间，平台收
     * 到推送后向停车系统提交减免申请，停车系统会根据入场时间，车牌等信息进行校验后减免
     * 充电停车费用。
     */
    public int assembleNotifyCarNumResult(NotifyCarNumReq notifyCarNumReq, TokenResult tokenResult,
                                          HlhtskBizOperator bizOperator, HlhtskBizTenant bizTenant) {
        //根据运营商operatorID找出对应的API
        HlhtParkingStrategy strategy = HlhtParkingStrategyFactory.getInstance().get(bizOperator.getHlhtOperatorId());
        if (strategy == null) {
            //throw new IllegalArgumentException("please input right type");
            logger.error("还没开通道闸对接");
            return 0;
        }

        return strategy.notify(notifyCarNumReq, tokenResult, bizOperator, bizTenant);
    }
}
